package com.xyc.common.utils;

import java.util.Calendar;
import java.util.Date;

public class DateUtils {

    private static Calendar calendar = Calendar.getInstance();

    /**
     * @Author xyc
     * @Date 2017/9/12 14:07
     * @Description 得到今天周几
     */
    public static int getTodayWeek() {


        calendar.setTime(new Date());
        int week = calendar.get(Calendar.DAY_OF_WEEK )-1;
        if (week < 0) week = 7;
        return week;

    }

    /**
     * @Author xyc
     * @Date 2017/9/12/012 14:07
     * @Description 计算时间差，分钟数
     */
    public static int getMinute(Date startDate, Date endDate) {

        long start = startDate.getTime();
        long end = endDate.getTime();
        int minute = (int) ((end - start) / (1000 * 60));
        return minute;
    }

    /**
     * @Author xyc
     * @Date 2017/9/12/012 14:14
     * @Description 获取当天的某个时间
     */
    public static Date getDate(int hour, int minute) {

        calendar.set(calendar.HOUR_OF_DAY, hour);
        calendar.set(calendar.MINUTE, minute);
        return calendar.getTime();


    }
}
